import "reflect-metadata"
import { Userinfo } from '../entity/UserInfo';
import Autowired from '../decorator/autowireddecortator';
import Singleton from '../decorator/singletondecrator';
import UserServiceImpl from '../service/UserServiceImpl';
import UserServiceInter from '../service/UserServiceInter';
// import CollectionInstance from '../collection';

class UserController {
  @Autowired('userServiceImpl') //Autowired 相当于注入：inject ，把外部的对象注入当前装饰器修饰的属性中
  @Autowired('userServiceImpl')
  @Singleton(false)
  private userServiceImpl!: UserServiceInter;

  public login(): void {
    // let userService: UserService = CollectionInstance.get('userService');
    // userService.register();
    // getOwnPropertyDescriptor :值的属性，如可写、可读、可用、value值等
    let UserServiceImpl: UserServiceImpl = Reflect.getOwnPropertyDescriptor(
      UserController.prototype,
      'userServiceImpl'
    )?.value;

    let userinfofrmdb = UserServiceImpl.Login('admin', '123');
    console.log(userinfofrmdb);

    // UserServiceImpl.register();
  }
}

let controller = new UserController();
controller.login();
export {};
